package com.gxa.client_shoppings.service.impl;

import com.gxa.client_shoppings.mapper.PayTypeMapper;
import com.gxa.client_shoppings.pojo.PayType;
import com.gxa.client_shoppings.service.PayTypeService;
import com.gxa.client_shoppings.utils.CreateNumber;
import com.gxa.client_shoppings.utils.JsonResult;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author smile_ZhongXuan
 * @Date 2020/11/16 10:08
 * @Version 1.0
 */
@Service("payTypeService")
public class PayTypeServiceImpl implements PayTypeService {

    @Resource
    PayTypeMapper payTypeMapper = null;
    JsonResult jsonResult = new JsonResult();

    @Override
    public Integer payTypeAdd(PayType payType) {
        payType.setSort(0);
        payType.setState(false);
        payType.setAppid(CreateNumber.getRandomString_a1(18));
        payType.setAppsecret(CreateNumber.getRandomString_a1(22));
        payType.setBusinessnum(CreateNumber.getRandomStringNum(10));
        payType.setDefaultpwd(CreateNumber.getRandomPassword(22));
        return payTypeMapper.insertSelective(payType);
    }

    @Override
    public Integer payTypeUpdate(PayType payType) {
        return payTypeMapper.updateByPrimaryKeySelective(payType);
    }

    @Override
    public Integer payTypeState(Integer id, Boolean state) {
        PayType payType = new PayType();
        payType.setId(id);
        payType.setState(state);
        return payTypeMapper.updateByPrimaryKeySelective(payType);
    }

    @Override
    public Integer payTypeSort(Integer id, Integer sort) {
        PayType payType = new PayType();
        payType.setId(id);
        payType.setSort(sort);
        return payTypeMapper.updateByPrimaryKeySelective(payType);
    }

    @Override
    public List<PayType> payTypeList() {
        return payTypeMapper.selectAll();
    }
}
